<template>
    <view>
        <f-signature @getImg="getImg"></f-signature>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                from: '',
                submitflag: fale
            }
        },
        onLoad(options) {
            if (options.from) {
                this.from = options.from
            }
        },
        methods: {
            getImg(e) {
                if (!this.submitflag) {
                    this.submitflag = true
                    uni.showLoading({
                        title: '正在保存'
                    })
                    this.$req.uploadImg(e).then(res => {
                        if (this.from == 'reg') {
                            uni.hideLoading()
                            this.submitflag = false
                            let pages = getCurrentPages(); //获取所有页面栈实例列表
                            let nowPage = pages[pages.length - 1]; //当前页页面实例
                            let prevPage = pages[pages.length - 2]; //上一页页面实例
                            prevPage.$vm.signature = res.data.data
                            uni.navigateBack()
                        } else {
                            this.$req.post('/doctor/updateqm', {
                                doctorid: uni.getStorageSync('uid'),
                                qianming: res.data.data
                            }).then(res => {
                                this.submitflag = false
                                uni.hideLoading()
                                uni.navigateBack()
                            })
                        }
                    })
                }
            }
        }
    }
</script>

<style>

</style>